﻿<!DOCTYPE html>
<html lang="en">
<head>
    <title>宾果高校</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <link rel="stylesheet" href="../css/sweetalert.min.css" />
    <script src="../js/jquery-1.12.2.min.js"></script>
    <script src="../js/linq.min.js"></script>
    <script src="../js/validator.min.js"></script>
    <script src="../js/common.js"></script>
    <script src="../js/angular.min.js"></script>
    <script src="../js/Controller.js"></script>
    <script src="../js/sweetalert.min.js"></script>
    <script src="../js/store.min.js"></script>
    <script>

        $("#searchPage").load("header.html", function () {
            SetCss("Info");
        });

        var mode;
        var id;
        var app = angular.module('myApp1', []);
        var param = common.getUrlArgStr();

        if (param.mode != undefined && param.mode != "") {
            mode = param.mode;

            app.controller('MyCtrl', function ($http, $scope) {
                $http.get('../api/student/GetInfo/').success(function (data) {

                    $("#divSchool").hide();
                    $scope.names = data.ResponseDict;
                    id = data.ResponseDict.StudentNO;
                    //$("#SchoolNO").val(data.ResponseDict.SchoolNO);
                    $("#Major").val(data.ResponseDict.Major);
                    $("#Education").val(data.ResponseDict.Education);
                    $("#EntranceDate").val(data.ResponseDict.EntranceDate);
                    $("#StudentLDNumber").val(data.ResponseDict.StudentLDNumber);
                    $("#Name").val(data.ResponseDict.Name);
                    $("#BankNO").val(data.ResponseDict.BankNO);
                    $("#AliPayNO").val(data.ResponseDict.AliPayNO);
                    

                }).error(function (data, status, headers, config) {

                    common.alertMessage(data.Message, status);
                });

            });
        }

        common.commonAjax({ type: 'get', url: '../api/student/ListSchool', sMethod: AfteAjax1 });

        var data;

        function changeCity(pno) {

            $("#SchoolNO").empty();

            if (pno == "0" || pno == "" || pno == undefined)
                return;

            Enumerable.From(data).Where("$.CityNO == " + pno + "").ForEach(function (obj) {
                $("#SchoolNO").append("<option value='" + obj.SchoolNO + "'>" + obj.SchoolName + "</option>")
            })
        }


        function AfteAjax1(ctx) {
            if (ctx == "" || ctx == null) {
                common.alertMessage("提交错误，请重试！");
                return;
            }

            data = ctx.ResponseList;

            var str = [];

            //var res = Enumerable.From(data);

            var result = Enumerable.From(data).ForEach(function (obj) {

                if (obj.CityNO == 0)
                    return;

                if (str.indexOf(obj.CityNO) >= 0)
                    return;

                str.push(obj.CityNO);

                $("#provinces").append("<option value='" + obj.CityNO + "'>" + obj.CityName + "</option>")
            });
        }

        function AfteAjax(ctx) {

            if (ctx == "" || ctx == null) {
                common.alertMessage("提交错误，请重试！");
                return;
            }

            if (mode == "edit")
                window.location = "info.html";
            else {
                var user = store.get("User");
                user.StudentID = ctx.ResponseStr;
                store.set("User", user);

                window.location = "Step2.aspx";
            }

        }

        function Go() {

            if (!common.validateForm())
                return;

            var values = common.GetCtrlValues({
                ContentID: "formValidate"
            })


            values["SchoolName"] = $("#SchoolNO").find("option:selected").text();
            //values["Nature"] = $("#NatureNO").find("option:selected").text();
            //values["CSizeDisplayName"] = $("#CSize").find("option:selected").text();
            //values["Type"] = $("#TypeNO").find("option:selected").text();

            if (mode == "edit") {
                common.commonAjax({ type: 'Put', url: '../api/student/put/' + id, data: values, sMethod: AfteAjax, alert: true, loadingCtrl: $("#person-audit") });
            }
            else
                common.commonAjax({ type: 'Post', url: '../api/student/post', data: values, sMethod: AfteAjax, alert: true, loadingCtrl: $("#person-audit") });
        }



    </script>
</head>
<body id="person-audit">
    <div id="searchPage"></div>
    <div class="main">
        <div class="audit-banner text-center">
            <h1>Open Person Service</h1>
            <p>进行个人验证</p>
        </div>
        <div class="wrap">
            <div class="audit-wrap step-header">
                <ul class="clearfix">
                    <li>
                        <h2 style="color: #FF4500;" class="text-center">01</h2>
                        <div>提交个人基本信息</div>
                    </li>
                    <div class="step-line"></div>
                    <li>
                        <h2 class="text-center">02</h2>
                        <div>提交身份信息</div>
                    </li>
                </ul>
            </div>
            <div class="audit-wrap step">
                <form id="formValidate" action="" ng-app="myApp1" ng-controller="MyCtrl" class="form-horizontal">
                    <div class="form-group form-inline" id="divSchool">
                        <label for="" style="display: block;">所属高校</label><span>广东省 一</span>
                        <select id="provinces" name="" style="width: 210px;" onchange="changeCity(this.value)" class="form-control input-sm">
                            <option value="">请选择学校所在城市</option>
                        </select><span> 一</span>
                        <select id="SchoolNO" name="" style="width: 210px;" class="form-control input-sm">
                            <option value="">请选择学校</option>
                        </select>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <input type="text" id="Major" placeholder="所属院系" data-error="请填写所属院系" required class="form-control">
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <select id="Education" class="form-control" data-error="请选择学历" required min="1">
                            <option value="">请选择学历</option>
                            <option value="大专">大专</option>
                            <option value="本科">本科</option>
                            <option value="研究生">研究生</option>
                            <option value="博士生">博士生</option>
                        </select>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <select id="EntranceDate" class="form-control" data-error="请选择入学年份" required min="1">
                            <option value="">请选择入学年份</option>
                            <option value="2016-09-01 00:00:00">2016年</option>
                            <option value="2015-09-01 00:00:00">2015年</option>
                            <option value="2014-09-01 00:00:00">2014年</option>
                            <option value="2013-09-01 00:00:00">2013年</option>
                            <option value="2012-09-01 00:00:00">2012年</option>
                            <option value="2011-09-01 00:00:00">2011年</option>
                            <option value="2010-09-01 00:00:00">2010年</option>
                            <option value="2009-09-01 00:00:00">2009年</option>
                            <option value="2008-09-01 00:00:00">2008年</option>
                        </select>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <input type="number" id="StudentLDNumber" placeholder="学号" data-error="请填写学号" required class="form-control">
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <input type="text" id="Name" placeholder="姓名" data-error="请填写姓名" required class="form-control">
                        <div class="help-block with-errors"></div>
                    </div>
                    <!--<div class="form-group">
                        <input type="number" id="Phone" placeholder="联系电话" readonly class="form-control">
                    </div>-->
                    <div class="form-group">
                        <input type="email" id="BankNO" placeholder="联系邮箱" data-error="请填写联系邮箱" required class="form-control">
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <input type="text" id="AliPayNO" placeholder="联系QQ" data-error="请填写联系QQ" required class="form-control">
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group text-center">
                        <button type="button" onclick="Go()" class="btn btn-default">下一步</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</body>
</html>